<template>
  <div>
    <h2>new worker</h2>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="编号" width="80"> </el-table-column>
      <el-table-column prop="name" label="姓名"> </el-table-column>
      <el-table-column prop="age" label="年龄"> </el-table-column>
      <el-table-column prop="gender" label="性别"> </el-table-column>
    </el-table>
  </div>
</template>
<script>
import dataWorker from "./dataWorker.worker.js";
export default {
  data() {
    return {
      tableData: [],
    };
  },
  async created() {
    this.getData();
    const worker = new dataWorker();
    worker.postMessage(this.tableData);
    worker.addEventListener("message", (e) => {
        worker.terminate();
        this.tableData = this.tableData.concat(e.data);
    });
  },
  methods: {
    async getData() {
      const res = await this.$http.get("/user/list");
      console.log("res", res);
      this.tableData = res.data;
    },
  },
};
</script>
